﻿<Application x:Class="Knowledgecast.Twitter.WPF.App.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:twitter="clr-namespace:Knowledgecast.Twitter;assembly=Knowledgecast.Twitter"
    xmlns:twitterwpf="clr-namespace:Knowledgecast.Twitter.WPF;assembly=Knowledgecast.Twitter.WPF"
    StartupUri="Window1.xaml">
    <Application.Resources>
        <twitterwpf:StatusInfoConverter x:Key="StatusInfoConverter" />
        <twitterwpf:StatusConverter x:Key="StatusConverter" />
        <twitterwpf:StatusSourceConverter x:Key="StatusSourceConverter" />
        <twitterwpf:TimeConverter x:Key="TimeConverter" />
        <BlurEffect x:Key="Blur" Radius="1" />
        <DataTemplate x:Key="StatusTemplate">
            <Border BorderBrush="LightGray" BorderThickness="2" Margin="5" CornerRadius="5" Background="WhiteSmoke">
                <Border.Resources>
                    <Storyboard x:Key="ShowButtons">
                        <DoubleAnimation BeginTime="00:00:00" Duration="00:00:00.2" To="1" Storyboard.TargetProperty="Opacity" />
                    </Storyboard>
                    <Storyboard x:Key="HideButtons">
                        <DoubleAnimation BeginTime="00:00:00" Duration="00:00:00.2" To="0" Storyboard.TargetProperty="Opacity" />
                    </Storyboard>
                    <Style x:Key="MouseOverStyle" TargetType="Grid">
                        <Style.Triggers>
                            <EventTrigger RoutedEvent="MouseEnter">
                                <BeginStoryboard Storyboard="{StaticResource ShowButtons}" />
                            </EventTrigger>
                            <EventTrigger RoutedEvent="MouseLeave">
                                <BeginStoryboard Storyboard="{StaticResource HideButtons}" />
                            </EventTrigger>
                        </Style.Triggers>
                    </Style>
                </Border.Resources>
                <Grid Margin="2" >
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Image Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="2" Source="{Binding User.ProfileImageUrl}" Width="48" Height="48" />
                    <Grid Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="2" Style="{StaticResource MouseOverStyle}" Opacity="0">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Rectangle Grid.Row="0" Grid.RowSpan="2" Grid.Column="0" Grid.ColumnSpan="2" Fill="Red" Opacity="0" />
                        <Button Grid.Row="0" Grid.Column="0" ToolTip="Reply" Command="twitterwpf:TwitterCommands.ReplyMessage" CommandParameter="{Binding}" Content="R" VerticalAlignment="Center" HorizontalAlignment="Center" Width="20" Height="20" Margin="2" />
                        <Button Grid.Row="0" Grid.Column="1" ToolTip="Send direct message" Command="twitterwpf:TwitterCommands.DirectMessage" CommandParameter="{Binding}" Content="DM" VerticalAlignment="Center" HorizontalAlignment="Center" Width="20" Height="20" Margin="2" />
                        <Button Grid.Row="1" Grid.Column="0" ToolTip="Retweet" Command="twitterwpf:TwitterCommands.Retweet" CommandParameter="{Binding}" Content="RT" VerticalAlignment="Center" HorizontalAlignment="Center" Width="20" Height="20" Margin="2" />
                        <Button Grid.Row="1" Grid.Column="1" ToolTip="Other actions" Command="twitterwpf:TwitterCommands.OtherActions" CommandParameter="{Binding}" Content="O" VerticalAlignment="Center" HorizontalAlignment="Center" Width="20" Height="20" Margin="2" />
                    </Grid>
                    <twitterwpf:RichTextBlock Grid.Row="0" Grid.Column="1" RichText="{Binding Text,Converter={StaticResource StatusConverter}}" TextWrapping="Wrap" Foreground="Gray" VerticalAlignment="Top" Margin="2" />
                    <WrapPanel Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Margin="0, 5, 0, 0" Orientation="Horizontal" >
                        <twitterwpf:RichTextBlock RichText="{Binding User.ScreenName,Converter={StaticResource StatusInfoConverter}}" />
                        <TextBlock Text=" " />
                        <TextBlock Text="{Binding CreatedAt,Converter={StaticResource TimeConverter}}" />
                        <twitterwpf:RichTextBlock RichText="{Binding Source,Converter={StaticResource StatusSourceConverter}}" />
                    </WrapPanel>
                    <!--<TextBlock Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Text="{Binding}" Foreground="Gray" Margin="0, 5, 0, 0" />-->
                </Grid>
            </Border>
        </DataTemplate>
    </Application.Resources>
</Application>
